<?php
/*
 * @Author: your name
 * @Date: 2020-10-22 11:01:40
 * @LastEditTime: 2020-10-22 14:22:15
 * @LastEditors: Please set LastEditors
 * @Description: 模块登录
 * @FilePath: /special/application/api/service/client_login/LoginService.php
 */
namespace app\api\service\client_login;

use app\common\exception\CustomException;
use app\common\service\HostModuleRelation;

class ClientLoginService extends LoginService
{
    public $module = 'client';
    /**
     * @name: 客户端登陆
     * @Param:
     * @Description:
     * @Author: foo
     * @Date: 2019-12-07 14:06:23
     */
    public function login()
    {
        $HostModuleRelation = new HostModuleRelation();

        $field = 'client, netfilter, disguise';
        $config = $HostModuleRelation->findByHostId($this->host_id, $field);

        if(empty($config))
        {
            throw new CustomException('未找到主机配置', 422);
        }

        $return = [];
        foreach ($config as $k => $v)
        {
            $return[] = [
                'name' => $k,
                'enable' => $v ? true : false,
            ];
        }

        return $return;
    }
}